#include <stdio.h>
int main() {
    int n, digit = 0, temp;
    printf("请输入不多于5位的正整数：");
    scanf("%d", &n);
    temp = n;

    // 确定数字位数
    if (temp >= 10000) digit = 5;
    else if (temp >= 1000) digit = 4;
    else if (temp >= 100) digit = 3;
    else if (temp >= 10) digit = 2;
    else if (temp >= 1) digit = 1;
    else { printf("输入非法！\n"); return 1; }

    printf("位数：%d\n", digit);
    // switch按位数提取各位数字
    switch (digit) {
        case 5:
            printf("每一位：%d %d %d %d %d\n", temp/10000, temp/1000%10, temp/100%10, temp/10%10, temp%10);
            printf("逆序：%d %d %d %d %d\n", temp%10, temp/10%10, temp/100%10, temp/1000%10, temp/10000);
            break;
        case 4:
            printf("每一位：%d %d %d %d\n", temp/1000, temp/100%10, temp/10%10, temp%10);
            printf("逆序：%d %d %d %d\n", temp%10, temp/10%10, temp/100%10, temp/1000);
            break;
        case 3:
            printf("每一位：%d %d %d\n", temp/100, temp/10%10, temp%10);
            printf("逆序：%d %d %d\n", temp%10, temp/10%10, temp/100);
            break;
        case 2:
            printf("每一位：%d %d\n", temp/10, temp%10);
            printf("逆序：%d %d\n", temp%10, temp/10);
            break;
        case 1:
            printf("每一位：%d\n逆序：%d\n", temp, temp);
            break;
    }
    return 0;
}